<div class="row">
	<div class="col-xs-12 col-md-12">

		<div class="widget">
			<div class="widget-header bordered-bottom bordered-themeprimary">
				<i class="widget-icon fa fa-tasks themeprimary"></i>
				<span class="widget-caption themeprimary">订单详情</span>
				<div class="widget-buttons buttons-bordered">
					<%= button_to '编辑', edit_order_path(@order), method: :get, :class => "btn btn-blue btn-xs" %>
				</div>
			</div><!--Widget Header-->
			<div class="widget-body">
				<div class="widget-main no-padding">
					<table class="table table-bordered table-hover table-sm table-responsive">
						<thead>
							<tr>
								<th>订单号</th>
								<th>客户</th>
								<th>客户订单号</th>
								<th>交期</th>
								<th>备注</th>

							</tr>
						</thead>
						<tbody>
							<tr>
								<td><%= @order.order_code %></td>
								<td><%= @order.customer.name %></td>
								<td><%= @order.customer_po %></td>
								<td><%= @order.due_date %></td>
								<td><%= @order.comment %></td>
							</tr>
						</tbody>

					</table>

				</div><!--Widget Main Container-->
			</div><!--Widget Body-->
		</div>

		<div class="widget">
			<div class="widget-header bordered-bottom bordered-themeprimary">
				<i class="widget-icon fa fa-tasks themeprimary"></i>
				<span class="widget-caption themeprimary">产品详情</span>
				<div class="widget-buttons buttons-bordered">
					<%= button_to '添加产品', new_order_item_path(@order), method: :get, :class => "btn btn-blue btn-xs" %>
				</div>
				<div class="widget-buttons buttons-bordered">
					<%= button_to 'Print Invoice', '/', method: :get, :class => "btn btn-blue btn-xs" %>
				</div>
				<div class="widget-buttons buttons-bordered">
					<%= button_to 'Print PL', '', method: :get, :class => "btn btn-blue btn-xs" %>
				</div>
			</div><!--Widget Header-->
			<div class="widget-body">
				<div class="widget-main no-padding">

					<table class="table table-bordered table-striped table-condensed flip-content">
						<thead class="flip-content bordered-palegreen">
							<tr>
								<th>物料编码</th>
								<th>物料名称</th>
								<th>规格型号</th>
								<th>单位</th>
								<th>数量</th>
								<th>单价</th>
								<th>税率</th>
								<th>金额</th>
								<th></th>
								<th></th>
							</tr>
						</thead>
						<tbody>
							<% total = 0 %>
							<% @order.items.each do |item| %>
							<tr>
								<td><%= item.product_pn %> </td>
								<td><%= item.product_name %> </td>
								<td><%= item.product_desc %> </td>
								<td><%= item.unit %> </td>
								<td><%= item.quantity %></td>
								<td><%= item.unit_price %></td>
								<td><%= item.tax %></td>
								<td><%= item.amount %></td>
								<td><%= item.comment %></td>
								<td><%= link_to image_tag('edit.gif'), edit_order_item_path(@order,item) %> </td>
								<td><%= link_to image_tag('trash.gif'), order_item_path(@order,item), method: :delete, data: { confirm: 'Are you sure?' } %></td>
							</tr>
							<% total += item.quantity * item.unit_price %>
							<% end %>

						</tbody>
						<tfoot>
							<tr>
								<td colspan="3"><b>合计</b></td>
								<td><%= total %></td>
								<td></td>
								<td></td>
							</tr>
						</tfoot>
					</table>

				</div><!--Widget Main Container-->
			</div><!--Widget Body-->
		</div>

		<div class="widget">
			<div class="widget-header bordered-bottom bordered-themeprimary">
				<i class="widget-icon fa fa-tasks themeprimary"></i>
				<span class="widget-caption themeprimary">物流信息</span>
				<div class="widget-buttons buttons-bordered">
					<%= button_to '添加物流信息', new_shipping_path, method: :get, :class => "btn btn-blue btn-xs", params: {order_id: @order.id} %>
				</div>
			</div><!--Widget Header-->
			<div class="widget-body">
				<div class="widget-main no-padding">
					<% if @order.shippings.present? %>
					<table class="table table-bordered table-striped table-condensed flip-content">
						<thead class="flip-content bordered-palegreen">
							<tr>
								<th>发货日期</th>
								<th>物流方式</th>
								<th>物流公司</th>
								<th>物流单号</th>
								<th>尺寸(长*宽*高 mm)</th>
								<th>重量(kg)</th>
								<th>价格</th>
								<th>备注</th>
								<th></th>
								<th></th>
							</tr>
						</thead>
						<tbody>
							<% @order.shippings.each do |shipping| %>
							<tr>
								<td><%= shipping.date %></td>
								<td><%= shipping.method %></td>
								<td><%= shipping.carrier %></td>
								<td><%= shipping.tracking %></td>
								<td><%= shipping.weight %></td>
								<td><%= shipping.dimension %></td>
								<td><%= shipping.price %></td>
								<td><%= shipping.comment %></td>
								<td><%= link_to image_tag('edit.gif'), edit_shipping_path(shipping) %> </td>
								<td><%= link_to image_tag('trash.gif'), shipping_path(shipping), method: :delete, data: { confirm: 'Are you sure?' } %></td>
							</tr>
							<% end %>
						</tbody>
					</table>
					<% else %>
					此订单还未有物流信息！
					<% end%>

				</div><!--Widget Main Container-->
			</div><!--Widget Body-->
		</div>

		<div class="widget">
			<div class="widget-header bordered-bottom bordered-themeprimary">
				<i class="widget-icon fa fa-tasks themeprimary"></i>
				<span class="widget-caption themeprimary">开票信息</span>
				<div class="widget-buttons buttons-bordered">
					<%= button_to '开票', new_invoice_path, method: :get, :class => "btn btn-blue btn-xs", params:{order_id:@order.id} %>
				</div>
			</div><!--Widget Header-->
			<div class="widget-body">
				<div class="widget-main no-padding">
					<% if @order.orders_invoices.present? %>
					<table class="table table-bordered table-striped table-condensed flip-content">
						<thead class="flip-content bordered-palegreen">
							<tr>
								<th>开票日期</th>
								<th>客户</th>
								<th>发票号码</th>
								<th>发票代码</th>
								<th>开票编码</th>
								<th>结算单号</th>
								<th>税率</th>
								<th>金额</th>
							</tr>
						</thead>
						<tbody>

							<% total = 0
							@order.invoices.each do |invoice|%>
							<tr>
								<td><%= invoice.invoice_date %></td>
								<td><%= invoice.customer.name %></td>
								<td><%= invoice.invoice_no %></td>
								<td><%= invoice.invoice_code %></td>
								<td><%= invoice.invoice_index_code %></td>
								<td><%= invoice.settlement_slip_no %></td>
								<td><%= invoice.tax_rate %></td>
								<td><%= invoice.amount %></td>

							</tr>
							<% total += invoice.amount %>
							<% end %>
						</tbody>
						<tfoot>
							<th colspan="7">合计</th>
							<th> <%= total %></th>

						</tfoot>
					</table>
					<% else %>
					此订单还未开具发票！
					<% end %>
				</div><!--Widget Main Container-->
			</div><!--Widget Body-->

		</div>

		<div class="widget">
			<div class="widget-header bordered-bottom bordered-themeprimary">
				<i class="widget-icon fa fa-tasks themeprimary"></i>
				<span class="widget-caption themeprimary">付款信息</span>
				<div class="widget-buttons buttons-bordered">
					<%= button_to '添加付款', new_order_payment_path(@order), method: :get, :class => "btn btn-blue btn-xs", params: {order_id: @order.id} %>
				</div>
			</div><!--Widget Header-->

			<div class="widget-body">
				<div class="widget-main no-padding">
					<% if @order.payments.present?%>
					<table class="table table-bordered table-striped table-condensed flip-content">
						<thead class="flip-content bordered-palegreen">
							<tr>

								<th>付款日期</th>
								<th>付款金额</th>
								<th>客户付款流水单号</th>
								<th>备注</th>
								<th></th>

							</tr>
						</thead>
						<tbody>
							<%
							total = 0
							@order.payments.each do |payment| %>
							<tr>
								<td><%= payment.date %></td>
								<td><%= payment.amount %></td>
								<td><%= payment.tx_code %> </td>
								<td><%= payment.comment %> <td><%= link_to image_tag('edit.gif'), edit_order_payment_path(@order,payment) %>
								<%= link_to image_tag('trash.gif'), order_payment_path(@order,payment), method: :delete, data: { confirm: 'Are you sure?' } %></td>
							</tr>
							<% total += payment.amount %>
							<% end %>
						</tbody>
						<tfoot>
							<th colspan="">合计</th>
							<th><%= total%></th>
						</tfoot>
					</table>
					<% else %>
					<span>此订单还未付款！</span>
					<%end %>
				</div><!--Widget Main Container-->
			</div><!--Widget Body-->
		</div>


		<div class="widget">
			<div class="widget-header bordered-bottom bordered-themeprimary">
				<i class="widget-icon fa fa-tasks themeprimary"></i>
				<span class="widget-caption themeprimary">签单信息</span>				
			</div><!--Widget Header-->

			<div class="widget-body">
				<div class="widget-main no-padding">
					<div class="widget-buttons buttons-bordered">
					<%= button_to '上传签单', new_order_payment_path(@order), method: :get, :class => "btn btn-blue btn-xs", params: {order_id: @order.id} %>
				</div>
					
					
					
				</div><!--Widget Main Container-->
			</div><!--Widget Body-->
		</div>





	</div>
</div>

